/**
 * Copyrigth 2007 Aurelien Moreau
 * 
 * This file is part of ProcessShop.
 * 
 * ProcessShop is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * ProcessShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with ProcessShop; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * $Id$
 */
package net.yienyien.process.dfm.impl;

import java.util.Collection;

import net.yienyien.process.dfm.DataActivity;
import net.yienyien.process.dfm.DataLink;
import net.yienyien.process.dfm.DfmPackage;
import net.yienyien.process.dfm.Map;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Data Link</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link net.yienyien.process.dfm.impl.DataLinkImpl#getInputActivity <em>Input Activity</em>}</li>
 *   <li>{@link net.yienyien.process.dfm.impl.DataLinkImpl#getOutputActivity <em>Output Activity</em>}</li>
 *   <li>{@link net.yienyien.process.dfm.impl.DataLinkImpl#getMaps <em>Maps</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DataLinkImpl extends EObjectImpl implements DataLink {
	/**
	 * The cached value of the '{@link #getInputActivity() <em>Input Activity</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInputActivity()
	 * @generated
	 * @ordered
	 */
	protected DataActivity inputActivity;

	/**
	 * The cached value of the '{@link #getOutputActivity() <em>Output Activity</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutputActivity()
	 * @generated
	 * @ordered
	 */
	protected DataActivity outputActivity;

	/**
	 * The cached value of the '{@link #getMaps() <em>Maps</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMaps()
	 * @generated
	 * @ordered
	 */
	protected EList<Map> maps;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DataLinkImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DfmPackage.Literals.DATA_LINK;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DataActivity getInputActivity() {
		if (inputActivity != null && inputActivity.eIsProxy()) {
			InternalEObject oldInputActivity = (InternalEObject)inputActivity;
			inputActivity = (DataActivity)eResolveProxy(oldInputActivity);
			if (inputActivity != oldInputActivity) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, DfmPackage.DATA_LINK__INPUT_ACTIVITY, oldInputActivity, inputActivity));
			}
		}
		return inputActivity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DataActivity basicGetInputActivity() {
		return inputActivity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInputActivity(DataActivity newInputActivity) {
		DataActivity oldInputActivity = inputActivity;
		inputActivity = newInputActivity;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DfmPackage.DATA_LINK__INPUT_ACTIVITY, oldInputActivity, inputActivity));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DataActivity getOutputActivity() {
		if (outputActivity != null && outputActivity.eIsProxy()) {
			InternalEObject oldOutputActivity = (InternalEObject)outputActivity;
			outputActivity = (DataActivity)eResolveProxy(oldOutputActivity);
			if (outputActivity != oldOutputActivity) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, DfmPackage.DATA_LINK__OUTPUT_ACTIVITY, oldOutputActivity, outputActivity));
			}
		}
		return outputActivity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DataActivity basicGetOutputActivity() {
		return outputActivity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOutputActivity(DataActivity newOutputActivity) {
		DataActivity oldOutputActivity = outputActivity;
		outputActivity = newOutputActivity;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DfmPackage.DATA_LINK__OUTPUT_ACTIVITY, oldOutputActivity, outputActivity));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Map> getMaps() {
		if (maps == null) {
			maps = new EObjectContainmentEList<Map>(Map.class, this, DfmPackage.DATA_LINK__MAPS);
		}
		return maps;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case DfmPackage.DATA_LINK__MAPS:
				return ((InternalEList<?>)getMaps()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DfmPackage.DATA_LINK__INPUT_ACTIVITY:
				if (resolve) return getInputActivity();
				return basicGetInputActivity();
			case DfmPackage.DATA_LINK__OUTPUT_ACTIVITY:
				if (resolve) return getOutputActivity();
				return basicGetOutputActivity();
			case DfmPackage.DATA_LINK__MAPS:
				return getMaps();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DfmPackage.DATA_LINK__INPUT_ACTIVITY:
				setInputActivity((DataActivity)newValue);
				return;
			case DfmPackage.DATA_LINK__OUTPUT_ACTIVITY:
				setOutputActivity((DataActivity)newValue);
				return;
			case DfmPackage.DATA_LINK__MAPS:
				getMaps().clear();
				getMaps().addAll((Collection<? extends Map>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DfmPackage.DATA_LINK__INPUT_ACTIVITY:
				setInputActivity((DataActivity)null);
				return;
			case DfmPackage.DATA_LINK__OUTPUT_ACTIVITY:
				setOutputActivity((DataActivity)null);
				return;
			case DfmPackage.DATA_LINK__MAPS:
				getMaps().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DfmPackage.DATA_LINK__INPUT_ACTIVITY:
				return inputActivity != null;
			case DfmPackage.DATA_LINK__OUTPUT_ACTIVITY:
				return outputActivity != null;
			case DfmPackage.DATA_LINK__MAPS:
				return maps != null && !maps.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //DataLinkImpl
